{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Faceted Scatter Plot with Linked Brushing\n",
    "-----------------------------------------\n",
    "This is an example of using an interval selection to control the color of\n",
    "points across multiple facets.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# category: interactive\n",
    "\n",
    "import altair as alt\n",
    "alt.data_transformers.enable('json')\n",
    "from vega_datasets import data\n",
    "\n",
    "cars = data.cars()\n",
    "\n",
    "brush = alt.selection(type='interval', resolve='global')\n",
    "\n",
    "base = alt.Chart(cars).mark_point().encode(\n",
    "    y='Miles_per_Gallon',\n",
    "    color=alt.condition(brush, 'Origin', alt.ColorValue('gray'))\n",
    ").properties(\n",
    "    selection=brush,\n",
    "    width=250,\n",
    "    height=250\n",
    ")\n",
    "\n",
    "base.encode(x='Horsepower') | base.encode(x='Acceleration')\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "env": {},
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {},
   "name": "python3"
  },
  "language": "python"
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
